青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

asm, c, c++ are my all
-- Core In Computer
posts - 139,  comments - 123,  trackbacks - 0

********************************************\
|????歡迎轉載, 但請保留作者姓名和原文鏈接, 祝您進步并共勉!???? |
\********************************************/


C++對象模型(11) - 3.3 Access of a Data Member
作者: Jerry Cat
時間: 2006/11/15
鏈接:?
http://m.shnenglu.com/jerysun0818/archive/2006/11/15/15193.html


3.3 Access of a Data Member

1. Static Data Members:

Static data members are literally lifted out of their class, as we saw in Section 1.1 and treated as if each were declared as a global variable (but with visibility limited to the scope of the class).但其可視范圍只在類內.

Each member's access permission and class association is maintained without incurring any space or runtime overhead either in the individual class objects or in the static data member itself.

A single instance of each class static data member is stored within the data segment of the program. Each reference to the static member is internally translated to be a direct reference of that single extern instance. For example,

// origin.chunkSize == 250;
Point3d::chunkSize == 250;

// pt->chunkSize == 250;
Point3d::chunkSize == 250;

What if the access of the static data member is through a function call or some other form of expression? For example, if we write

foobar().chunkSize == 250;

what happens to the invocation of foobar()? In the pre-Standard language, one didn't know what would happen: It was left unspecified in the ARM whether foobar() had to be evaluated. In cfront, for example, it was simply discarded. Standard C++ explicitly requires that foobar() be evaluated, although no use is made of its result. A probable translation looks as follows:

// foobar().chunkSize == 250;

// evaluate expression, discarding result
(void) foobar();
Point3d::chunkSize == 250;
Taking the address of a static data member yields an ordinary pointer of its data type, not a pointer to class member, since the static member is not contained within a class object. For example,

&Point3d::chunkSize;
yields an actual memory address of type
const int*

2. Nonstatic Data Members:

Nonstatic data members are stored directly within each class object and cannot be accessed except through an explicit or implicit class object. An implicit class object is present whenever the programmer directly accesses a nonstatic data member within a member function. For example, in the following code:

Point3d
Point3d::translate( const Point3d &pt ) {
?? x += pt.x;
?? y += pt.y;
?? z += pt.z;
}
the seemingly direct access of x, y, and z is actually carried out through an implicit class object represented by the this pointer. Internally, the function is augmented as follows:

? // internal augmentation of member function
? Point3d
? Point3d::translate( Point3d *const this, const Point3d &pt ) {
???? this->x += pt.x;
???? this->y += pt.y;
???? this->z += pt.z;
? }

Access of a nonstatic data member requires the addition of the beginning address of the class object with the offset location of the data member. For example, given

origin._y = 0.0;
the address of

&origin._y;
is equivalent to the addition of

&origin + ( &Point3d::_y - 1 );//注意減1
(Notice the peculiar "subtract by one" expression applied to the pointer-to-data-member offset value. Offset values yielded by the pointer-to-data-member syntax are always bumped up by one. Doing this permits the compilation system to distinguish between a pointer to data member that is addressing the first member of a class and a pointer to data member that is addressing no member(減一用以讓編譯系統區分兩類數據成員指針: 一種是尋址第一個數據成員; 另一種是不對數據成員尋址). Pointers to data members are discussed in more detail in Section 3.6.)

編譯時確定, 效率不減.The offset of each nonstatic data member is known at compile time, even if the member belongs to a base class subobject derived through a single or multiple inheritance chain. Access of a nonstatic data member, therefore, is equivalent in performance to that of a C struct member or the member of a nonderived class.

Virtual inheritance introduces an additional level of indirection in the access of its members through a base class subobject. Thus

Point3d *pt3d;
pt3d->_x = 0.0;
performs equivalently if _x is a member of a struct, class, single inheritance hierarchy, or multiple inheritance hierarchy, but it performs somewhat slower if it is a member of a virtual base class. In the next sections, I examine the effect of inheritance on member layout. Before I turn to that, however, recall the question at the beginning of this section: When, if ever, is the access of the coordinate data members, such as

origin.x = 0.0;
pt->x = 0.0; //當面臨虛基類時&pt->x是不確定的, 而&origin.x則是在編譯時確定的
ever significantly different when accessed through the object origin or the pointer pt? The answer is the access is significantly different when the Point3d class is a derived class containing a virtual base class within its inheritance hierarchy and the member being accessed, such as x, is an inherited member of that virtual base class. In this case, we cannot say with any certainty which class type pt addresses (and therefore we cannot know at compile time the actual offset location of the member), so the resolution of the access must be delayed until runtime through an additional indirection. This is not the case with the object origin. Its type is that of a Point3d class, and the offset location of even inherited virtual base class members are fixed at compile time. An aggressive compiler can therefore resolve the access of x through origin statically.

posted on 2006-11-15 23:37 Jerry Cat 閱讀(1298) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理



<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用鏈接

留言簿(7)

隨筆檔案

最新隨筆

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久精品人人爽| 国产精品色在线| 欧美精品国产精品日韩精品| 欧美日韩免费网站| 国产亚洲成年网址在线观看| 亚洲精品欧美激情| 久久精品视频免费| 欧美制服丝袜| 国产精品海角社区在线观看| 亚洲高清123| 久久精品国产77777蜜臀| 午夜在线精品| 国产精品免费网站| 99视频有精品| 欧美国产高潮xxxx1819| 午夜精品成人在线| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 | 亚洲高清自拍| 日韩视频在线一区| 麻豆精品一区二区综合av| 国产午夜精品视频| 欧美国产日本韩| 久久久欧美精品| 狠狠噜噜久久| 久久天堂国产精品| 欧美专区中文字幕| 亚洲理伦电影| 亚洲福利电影| 免费亚洲网站| 久久成人精品电影| 国产一区二区三区免费不卡| 亚洲主播在线播放| 一本高清dvd不卡在线观看| 欧美激情综合在线| 欧美在线91| 久久精品免费看| 在线精品亚洲一区二区| 欧美.www| 欧美成人免费在线观看| 99精品视频免费| 一本综合精品| 国产精品卡一卡二卡三| 欧美高清在线视频| 国产伦精品一区二区三区照片91| 久久成人一区二区| 欧美一区二区视频在线观看2020| 国产亚洲综合精品| 日韩午夜av电影| 在线精品视频一区二区| 亚洲男人的天堂在线观看| 狠狠干综合网| 亚洲伊人伊色伊影伊综合网| 国内一区二区三区| 中国成人在线视频| 在线精品观看| 久久精品国产一区二区电影| 午夜精品理论片| 久久精品成人| 欧美在线综合视频| 国产精品呻吟| 亚洲一区在线直播| 亚洲永久字幕| 国产精品成人aaaaa网站| 久久久91精品国产一区二区三区 | 欧美一级一区| 久久精品一区二区三区中文字幕 | 免费视频一区| 欧美中在线观看| 国产精品免费观看视频| 亚洲视频中文| 亚洲精品视频免费观看| 麻豆精品视频| 亚洲黄色小视频| 国产亚洲精品aa午夜观看| 亚洲欧美日韩中文在线制服| 久久国产日韩欧美| 国产综合婷婷| 亚洲一区二区不卡免费| 午夜在线精品| 欧美日本在线观看| 麻豆精品传媒视频| 国产精品日韩欧美大师| 亚洲专区免费| 久久久久在线| 国产伦精品一区二区三区视频黑人 | 最近中文字幕日韩精品| 亚洲视频中文| 免费观看久久久4p| 日韩视频免费观看| 午夜精品一区二区在线观看| 国产午夜久久久久| 久久综合九色综合网站| 久久久久国色av免费看影院 | 欧美日韩免费网站| 午夜精品三级视频福利| 免费看亚洲片| 一区二区精品| 欧美激情欧美激情在线五月| 一本综合久久| 免费观看欧美在线视频的网站| 91久久国产精品91久久性色| 亚洲少妇一区| 噜噜噜在线观看免费视频日韩| 亚洲国内自拍| 国产欧美日韩另类一区| 亚洲欧美日韩综合aⅴ视频| 美女脱光内衣内裤视频久久影院 | 欧美一级播放| 亚洲欧洲视频| 国产视频久久| 欧美日韩一区二区精品| 久久精品国产免费观看| 9l视频自拍蝌蚪9l视频成人| 久久久久久97三级| 亚洲综合第一| 91久久夜色精品国产网站| 国产精品在线看| 欧美日韩精品综合在线| 日韩视频在线一区二区三区| 久久精品国产第一区二区三区| 亚洲黄色影片| 国产真实乱偷精品视频免| 欧美日韩美女在线| 欧美wwwwww| 米奇777在线欧美播放| 欧美在线首页| 亚洲小说欧美另类社区| 日韩视频在线你懂得| 欧美激情第五页| 久久久亚洲国产美女国产盗摄| 亚洲欧美高清| 伊人久久大香线蕉综合热线| 欧美va亚洲va香蕉在线| 久久精品欧洲| 午夜在线一区| 亚洲小视频在线| 亚洲无亚洲人成网站77777| 亚洲欧洲精品一区二区三区波多野1战4| 久久免费午夜影院| 久久精品毛片| 久久久久久久尹人综合网亚洲| 羞羞视频在线观看欧美| 亚洲一区二区三区激情| 在线观看成人小视频| 国外成人在线视频| 国内精品久久久| 国产亚洲欧美日韩日本| 激情五月婷婷综合| 国产精品久久久亚洲一区| 欧美先锋影音| 国产精品国产三级国产专播品爱网 | 久久久久国内| 另类人畜视频在线| 欧美mv日韩mv亚洲| 亚洲黄色在线| 99视频一区二区| 亚洲系列中文字幕| 午夜亚洲视频| 久久亚洲电影| 欧美一级艳片视频免费观看| 欧美一区二区高清| 久久九九精品99国产精品| 老牛嫩草一区二区三区日本 | 日韩一级黄色av| 亚洲专区欧美专区| 久久精品在线观看| 免费欧美在线| 欧美三级不卡| 欧美激情一区| 国产精品福利在线观看| 国产午夜精品理论片a级大结局| 国内精品久久国产| 日韩亚洲欧美精品| 欧美一区二区精品在线| 男女精品网站| 夜夜精品视频| 久久精品在线视频| 欧美三级日韩三级国产三级| 国产亚洲人成a一在线v站| 亚洲精品韩国| 久久国产精品久久w女人spa| 欧美成人免费小视频| 一区二区毛片| 久久蜜桃精品| 国产精品丝袜xxxxxxx| 亚洲二区在线视频| 午夜在线不卡| 亚洲国产精品综合| 亚洲精品欧美一区二区三区| 亚洲国产精品久久久久久女王| 亚洲深夜福利视频| 美女精品网站| 国产日韩精品在线观看| 在线亚洲免费| 欧美激情精品久久久久久蜜臀 | 欧美14一18处毛片| 亚洲一二三区视频在线观看| 欧美粗暴jizz性欧美20| 黄色影院成人| 欧美一区二区免费|